/*
 * @Author: wangjun haodreams@163.com
 * @Date: 2024-07-21 00:00:46
 * @LastEditors: wangjun haodreams@163.com
 * @LastEditTime: 2024-07-28 11:24:05
 * @FilePath: \gw\example\demo1.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import (
	"fmt"
	"log"
	"time"

	"gioui.org/app"
	"gioui.org/layout"
	"gioui.org/unit"
	"gitee.com/haodreams/gw"
)

func Init() *gw.Window {
	win := gw.NewWindow()
	win.Option(
		app.Title("Counter"),
		app.Size(unit.Dp(800), unit.Dp(600)),
	)

	header := gw.NewContainer(win)

	header.AddWidget(gw.NewLabel(win, "Hello:"))

	header.AddWidget(gw.NewEdit(win, "test"))
	header.AddWidget(gw.NewEdit(win, "test2"))
	header.Add(gw.NewSpacer(8))

	button := gw.NewButton(win, "Count", func() { log.Println(time.Now()) })
	header.Add(gw.NewSpacer(8))

	button2 := gw.NewButton(win, "test", func() { log.Println(time.Now()) })

	header.AddWidget(button)
	header.Add(gw.NewSpacer(8))

	header.Add(layout.Rigid(button2.Layout))

	tabs := gw.NewTabs(win)
	for i := 1; i <= 5; i++ {
		edit := gw.NewEdit(win, fmt.Sprintf("TEST Tab %d", i))
		edit.SetSigleLine(false)

		tab := gw.NewTab(win, fmt.Sprintf("Tab %d", i+1))
		tab.Add(layout.Flexed(1, edit.Layout))
		tabs.AddTab(tab)
	}

	root := gw.NewContainer(win)
	root.SetAxis(layout.Vertical)

	root.AddWidget(header)
	//root.Add(layout.Flexed(1, edit.Layout))
	root.Add(layout.Flexed(1, tabs.Layout))

	win.SetContent(root)
	return win
}

func main() {
	gw.Run(Init)
}
